home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / DLDeque.hP < prev    next >
Text File  |  1992-04-14  |  3KB  |  131 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T>DLDeque_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>DLDeque_h
  25.  
  26. #include "<T>.DLList.h"
  27. #include "<T>.Deque.h"
  28.  
  29. class <T>DLDeque : public <T>Deque
  30. {
  31.   <T>DLList    p;
  32.  
  33. public:
  34.                <T>DLDeque();
  35.                <T>DLDeque(const <T>DLDeque& d);
  36.                ~<T>DLDeque();
  37.  
  38.   void          operator = (const <T>DLDeque&);
  39.  
  40.   void          push(<T&> item); // insert at front
  41.   void          enq(<T&> item);  // insert at rear
  42.  
  43.   <T>&          front();
  44.   <T>&          rear();
  45.  
  46.   <T>           deq();
  47.   void          del_front();
  48.   void          del_rear();               
  49.  
  50.   void          clear();
  51.   int           empty();
  52.   int           full();
  53.   int           length();
  54.                
  55.   int           OK();
  56. };
  57.  
  58.  
  59. inline <T>DLDeque::<T>DLDeque() : p() {}
  60. inline <T>DLDeque::<T>DLDeque(const <T>DLDeque& d) : p(d.p) {}
  61.  
  62. inline <T>DLDeque::~<T>DLDeque() {}
  63.  
  64. inline void <T>DLDeque::push(<T&>item)
  65. {
  66.   p.prepend(item);
  67. }
  68.  
  69. inline void <T>DLDeque::enq(<T&>item)
  70. {
  71.   p.append(item);
  72. }
  73.  
  74. inline <T> <T>DLDeque::deq()
  75. {
  76.   return p.remove_front();
  77. }
  78.  
  79. inline <T>& <T>DLDeque::front()
  80. {
  81.   return p.front();
  82. }
  83.  
  84. inline <T>& <T>DLDeque::rear()
  85. {
  86.   return p.rear();
  87. }
  88.  
  89. inline void <T>DLDeque::del_front()
  90. {
  91.   p.del_front();
  92. }
  93.  
  94. inline void <T>DLDeque::del_rear()
  95. {
  96.   p.del_rear();
  97. }
  98.  
  99. inline void <T>DLDeque::operator =(const <T>DLDeque& s)
  100. {
  101.   p.operator = (s.p);
  102. }
  103.  
  104.  
  105. inline int <T>DLDeque::empty()
  106. {
  107.   return p.empty();
  108. }
  109.  
  110. inline int <T>DLDeque::full()
  111. {
  112.   return 0;
  113. }
  114.  
  115. inline int <T>DLDeque::length()
  116. {
  117.   return p.length();
  118. }
  119.  
  120. inline int <T>DLDeque::OK()
  121. {
  122.   return p.OK();
  123. }
  124.  
  125. inline void <T>DLDeque::clear()
  126. {
  127.   p.clear();
  128. }
  129.  
  130. #endif
  131.